package org.zoomdev.zoom.dao.adapters.statement;

import org.zoomdev.zoom.dao.adapters.StatementAdapter;

import java.io.StringReader;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class String2Clob implements StatementAdapter {
    @Override
    public void adapt(PreparedStatement statement, int index, Object value) throws SQLException {
        if (value == null) {
            statement.setObject(index, null);
        } else {
            String string = (String) value;
            statement.setCharacterStream(index, new StringReader(string), string.length());
        }
    }
}
